<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.sql.*" %>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>产品信息列表</title>
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/user.css">
    <script src="js/user.js"></script>
</head>

<body>

<div class="container-fluid">
    <div class="row">

        <div class="col-sm-12" id="right">
            <ol class="breadcrumb">
                <li class="active">菜单
                </li>
                <li class="active">编辑用户信息
                </li>
            </ol>

            <div class="panel panel-default">
                <div class="panel-heading">
                    填写用户信息
                </div>
                <div class="panel-body">
                    <%
                        String worknumber="";
                        String name="";
                        String department="";
                        String worktime="";
                        String degree="";
                        String profession="";
                        String title="";
                        String phonenumber="";
                        String address="";
                        String introduction="";
                        if(request.getParameter("worknumber")!=null)
                            worknumber = request.getParameter("worknumber");
                        if(request.getParameter("name")!=null)
                            name = request.getParameter("name");
                        if(request.getParameter("department")!=null)
                            department = request.getParameter("department");
                        if(request.getParameter("worktime")!=null)
                            worktime = request.getParameter("worktime");
                        if(request.getParameter("degree")!=null)
                            degree = request.getParameter("degree");
                        if(request.getParameter("profession")!=null)
                            profession = request.getParameter("profession");
                        if(request.getParameter("title")!=null)
                            title = request.getParameter("title");
                        if(request.getParameter("phonenumber")!=null)
                            phonenumber = request.getParameter("phonenumber");
                        if(request.getParameter("address")!=null)
                            address = request.getParameter("address");
                        if(request.getParameter("introduction")!=null)
                            introduction = request.getParameter("introduction");
                    %>
                    <form role="form" class="form-horizontal" action="person_add_do.jsp" method="post">
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">工号<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="worknumber" name="worknumber"
                                       value="<%=worknumber%>"
                                       placeholder="请输入工号">
                                <span id="worknumberError" class="errortext">
                                   <%
                                       worknumber = request.getParameter("worknumber");
                                       String pattern = "[0-9]{8}";
                                       if (worknumber != null) {
                                           if (worknumber == "") {
                                               out.println("工号不能为空");
                                           } else if (worknumber.length() != 8) {
                                               out.println("格式错误,长度应为8个数字");
                                           } else if (!worknumber.matches(pattern)) {
                                               out.println("格式错误,只能包含数字");
                                           }
                                       }

                                   %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">姓名<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="name" name="name"
                                       value="<%=name%>"
                                       placeholder="请输入姓名">
                                <span id="nameError" class="errortext">
                                  <%
                                      name = request.getParameter("name");
                                      if (name != null) {
                                          if (name == "") {
                                              out.println("姓名不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">部门<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <select class="form-control" id="department" name="department">
                                    <option value="">请选择</option>
                                    <option value="表面处理车间" <% if (department.equals("表面处理车间"))
                                        out.print("selected"); %> >表面处理车间
                                    </option>
                                    <option value="锻压车间" <% if (department.equals("锻压车间")) out.print("selected"); %> >
                                        锻压车间
                                    </option>
                                    <option value="组装车间" <% if (department.equals("组装车间")) out.print("selected"); %> >
                                        组装车间
                                    </option>
                                    <option value="质检车间" <% if (department.equals("质检车间")) out.print("selected"); %> >
                                        质检车间
                                    </option>
                                    <option value="机加车间" <% if (department.equals("机加车间")) out.print("selected"); %> >
                                        机加车间
                                    </option>
                                </select>
                                <span id="departmentError" class="errortext">
                                  <%
                                      department = request.getParameter("department");
                                      if (department != null) {
                                          if (department == "") {
                                              out.println("请选择所在部门");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">入职时间</label>
                            <div class="col-sm-8">
                                <input type="date" class="form-control" id="worktime" name="worktime"
                                       value="<%=worktime%>"
                                       placeholder="请输入入职时间" pattern="\d{4}-\d{2}-\d{2}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">最高学历<sup
                                    class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <select class="form-control" id="degree" name="degree">
                                    <option value="">请选择</option>
                                    <option value="小学" <% if (degree.equals("小学")) out.print("selected"); %>>小学
                                    </option>
                                    <option value="初中" <% if (degree.equals("初中")) out.print("selected"); %>>初中
                                    </option>
                                    <option value="高中" <% if (degree.equals("高中")) out.print("selected"); %>>高中
                                    </option>
                                    <option value="本科" <% if (degree.equals("本科")) out.print("selected"); %>>本科
                                    </option>
                                    <option value="研究生" <% if (degree.equals("研究生")) out.print("selected"); %>>
                                        研究生
                                    </option>
                                    <option value="博士" <% if (degree.equals("博士")) out.print("selected"); %>>博士
                                    </option>
                                </select>
                                <span id="degreeError" class="errortext">
                                  <%
                                      degree = request.getParameter("degree");
                                      if (degree != null) {
                                          if (degree == "") {
                                              out.println("请选择最高学历");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">专业<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="profession" name="profession"
                                       value="<%=profession%>"
                                       placeholder="请输入专业">
                                <span id="professionError" class="errortext">
                                  <%
                                      profession = request.getParameter("profession");
                                      if (profession != null) {
                                          if (profession == "") {
                                              out.println("专业不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">职称<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="title" name="title"
                                       value="<%=title%>"
                                       placeholder="请输入职称">
                                <span id="titleError" class="errortext">
                                  <%
                                      title = request.getParameter("title");
                                      if (title != null) {
                                          if (title == "") {
                                              out.println("职称不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">手机号<sup
                                    class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="phonenumber" name="phonenumber"
                                       value="<%=phonenumber%>"
                                       placeholder="请输入手机号">
                                <span id="phonenumberError" class="errortext">
                                  <%
                                      phonenumber = request.getParameter("phonenumber");
                                      String re = "1\\d{10}";
                                      if (phonenumber != null) {
                                          if (phonenumber == "") {
                                              out.println("手机号不能为空");
                                          } else if (!phonenumber.matches(re)) {
                                              out.println("手机号格式输入错误");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">家庭住址</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="address" name="address"
                                       value="<%=address%>"
                                       placeholder="请输入家庭住址">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">个人简介</label>
                            <div class="col-sm-8">
                                <textarea cols="50" rows="3" class="form-control" id="introduction" name="introduction"
                                          placeholder="请输入个人简介"><%=introduction%></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary">保存</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

</body>

</html>
